merged with martin's branch - includes many new things