Improved layout, fixed resource handling logic.