add alpha and minor optimizations