Bug 1019646 and Bug 1020473 and other improvements