Bug fixes

According to Anthony he found a few errors.