Fixed some bugs (still buggy)