Added PHPdoc documentation throughout.