some bug fixing and beautifying...