added phpdocs and did some code cleanup