[Refactor] Removed end_* related function and modified coding style