Merged changes from v0.5.2 in 0.5 branch