fix main layout file for small screens and code cleanup