Cleanup unused variables.
Reduce code complexity.
Improved docblocks.
Improved documentation