fixes and some code betterments