Clean up bugs and console warnings