Changed np to sp, plus some other small changes