phpDoc, refactor code & clean up