Added pseudocode in preparation for the next phase. Fixed a few bugs.