Lots of bugs fixed, some functionalities added