added config support, exported layout functions, refactoring