Made argument checking more robust, and fixed slice call