Updated from v0.12.1 changes from master branch