Fixed some code issues