Updated with jackhl 's fixes for warnings