Added PHPDoc and smaller bug fixes.