fixed minor errors, code cleanup