Code cleanup, fixed many gcc warnings