Minor code mistakes fixed in Esref's commit