fix warnings
fix malloc
cleanup