fixed lot of code issues