Fixed bugs in height functions