Spring Security stuff and some refactoring.