Finished implementing parallelization.

Fixed various bugs.