Fixed problem with Spring beans being null in some circumstances.