Some improvements. TODO: Fix structure and some dirty works