Cleaned code, added phpdoc, standardized indentation

see commit description