Fixing bugs, allocation, as well as extra compiler warnings