Removed unneeded includes, added documentation, reformatted some code for consistency.