Fixed various bugs.
Improved formatting