Refixing some bugs