Changed to not allocate more memory than necessary
Added real abort function, instead of just endless loop