A lot of new functions & optimizations

Signed-off-by: Xmister <xmisterhu@gmail.com>