Add some tests and try to fix the alias reuse issue. Still WIP.