Added profile size control
Added error test cases and refactored flash in layout