bug fixes related to casting objects