Fixed some issues in code