Big merge with other contributions - currently not working!