Reorganized everything. Fixed some compile time errors