Adding in fixes based on @danring's comments