Fixed bugs causing inconcistencies