Fixing bugs discovered by last commit