Bug fixes

Don't merge yet, Still need to test the functionalities