changed includes to c++-style
Fixed a memory leak in begin() and end() methods