added $removeByIndex and fix index removal