Updated structure, and fixed various bugs