Massive cleanup

Code clean up, code optimization, changed dir structure