Pulled out functions into raw_helpers for ease of unittesting. Refactored and removed uncessary code/comments.