Fixed issue with layout path, better error handling