Refactored a little bit around.