Removed some unused code (ported from old version, then rewritten)