Added block elimination algorithm and fixed array indexing problems