Preliminary testing, fixed a few bugs