Improved internal error checking
Make result of casting of constants constant
Merge branch 'experimental/Basia-A' of github.com:chung-leong/qb into experimental/Basia-A