cleanup, add require re
handle errors, fixes #45