Add layout. Fix phpdoc. Fix misc bugs.