checked generic correctness and removed compilation warnings