Refactored a couple functions; nothing fancy