Updated with bug fixes from origin