#330 Moved layout code to typescript