Cleaned up code a bit and fixed small math error that didn't hurt anything but looked bad.