Some minor refactorings

There's just a bunch of repeated code that I'd like to see 'merged'. This is not perfect either, but it's a start.