fixed things, should be fairly final (but messy)