Code refucktoring. Some classes are still broken but simple to fix.