fix warnings
fix memleak