Full restructure of code