TODO and bug fixes, layout fixes
Merged with upstream