[BUGFIX] Add trailing slash when needed
And also did a little bit of reformatting