Code re-factoring and layout improvements