Changed identation rules (spacing and width)
Removed dead code from numerous places
Moved shared functions into library class
Organized code to improve readability