fixed logic problems in php, fixed typos in templates ... enough for today!