implement platform codes
fix bugs in platform native codes