Correct some warnings and compile problems

Shall fix #3. Also include some clean ups.