Fix for bugs 1,2,3