Added cmake checks, tidied up
Made error codes negative
Relocated tests/samples to extra folder
Fixed some docs