Cleaned up + speed improvements.