Splitted things up a little to make it more maintainable.