Various bugs fixed.