Bug fixes

Fixed a windowing bug, cleaned up the connection code.