Fixing some more broker quirks and adding MIT License

1. The main thread now also does the broker work
2. Fixed issues with closing the pipe file descriptors correctly
3. More code cleanups
4. Adding a LICENSE