tried to fix a bunch of bugs. probably added more.

Signed-off-by: Brandon Ewoldt <bewoldt1@gmail.com>