Add Makefile and fix compiler warnings
add redirect and get_max_open