Added more testing, fixed a few bugs