Handle relative paths correctly

Signed-off-by: James Tasker <james_tasker1@hotmail.com>
Code refactor

Signed-off-by: James Tasker <james_tasker1@hotmail.com>