Code cleanup and directory structuring