Fix warnings + other minor refactoring

@dwightguth review?