Refactored some functions to new files

Signed-off-by: MaloW <malow@spray.se>