Fixing various issues and bugs