Added multi-instance handling to main() function.
Fixed IPC initialization + some code refactoring.
Handle incoming IPC commands in the "main" window.