Cleaned up some code and added in dir support again.