jamesu's console function refactor

Contains #81 and #664 merged with current dev head. All appears to be in order. Testing will be achieved by merging this into the dev branch and letting people find breakages.