Reformatted code + fixed equations