Fix some bugs

and (always) formatting issues