Add layout. Fix phpdoc. Fix misc bugs.

Add layout. Fix phpdoc. Fix misc bugs.