cleaning up some casts etc