Cleanup and make a bit more DRY