Added various improvements for perfomance