Updated and fixed some bugs