minor cleaning
further fixes
cleaned up some casts