Fixning bugs for upgrading to production level