Updated with a few bug fixes