Revamped the library code so that it relies on contrcats as opposed to strong-typed classes