Change order of if-statements
Use Pimpl idiom to reduce compiler dependencies