Added more documentation and compile-time checks