Restructured almost everything
Removed unused functions