[API, TEST, INTERNAL, DOC] Adds documentation, some minor refactorizations and  cleanses the code in general.