added more error handling, fixed relative paths