Restructuring and general cleanup