ported most commits from 2.0

includes:
a905d27bb894ee8f3a48c9d52cf12567dd6833b0
9a1eee6739f50fc781da1b74a85269f46bd105ce
5ff1426f4eaf91d98b8f0948b545b5638f48a201
3dab50890b563bfa7db7ef0298e0ef7ab2b99b4b
3bcac6e530cdc39af1fb261362044ad6f417886b