Fixed bugs and added some features