Cleaned up code and added comments

Signed-off-by: Wilco van den Brink <wilco.vandenbrink@outlook.com>