Mac OSX kernel

is there anyway of looking at, and if possible, modifying it?

Yes. It's called Darwin.
Link below:
Apple - Darwin - Releases

There is not really a way to "optimize and recompile" your kernel as with Linux, if that is what you are asking.

Go to Apple - Darwin - Releases for access to the source code for Darwin. If you don't need things like the iApps and the Apple GUI, then you can build your own Darwin machine.

Apple provides the developer tools for free on it's OS install media, or via the internet (with web developer account).