further refined connection handling in angular and added cookie support