Restructured code, added routes