Minor refactoring for Raptor

@martint  - Only the last commit needs to be reviewed. 
Other commits are a part of another PR that is not yet merged.