Fixed memory lag and got rid of compiler warnings.