Code cleanup

This PR contains some minor code cleanup, regarding following parts:
- Port input validation (must be an integer between 0 and 65535)
- Removed safe_server_address() since it wasn't necessary (I hope)
- Clean rewrite of convert_bytes() and merged functionality of format_number()

As far as I can tell there are no regressions, but i haven't tested the sabnzbd module.

This is a splitup of #187.