Major fixes

Nickolai(Cameron)'s code caused a lot of problems due to not updating
with current past revisions.