Cleanup up the code and set better defaults