Tests and a ton of improvements and modifications