Restructured code for further development