Major codecleanup part 1. compiling and working well