merged some changed from felixs' branch