Finished the test program and fixed some bugs.