Fixed some bugs and variable types