Merged fixes from v1.0.5 for 1.6.4