Fix some controller code, add comments