Cleaned up code and resolved warning messages