Major fixes to almost all functionalities