Added a skeleton for the final cost analyzer. Fixed a few bugs.