Improved the error management as well as some function renaming and reorganisation for clarity.
A few changes to the documentation