Fixed some bugs and added features