Bug fixes, fixed errors in test unit, merge conflicts.