Some cleanup and fixing possible issues