Fixed bugs 12, 9 and 23.