Code cleanup & reformatting

I did a lot of code cleanup and general reformatting. CraftZ's code
should be nicer to look at now, and possibly run a bit faster as well.
Also, I fixed a few bugs that could occur.