Add some documentation and reformat to PSR1/2 standards