almost

Still have a 'bug' with the setinv function, but don't have the time to
correct it