refactor and track down bugs, but mcem still boned