Some optimizations + scripts + test