Massive restructuring of the code style to PSR2.

Modified slightly to make it extendable.