improved the interfaces and added more type safety.