Code organization and some structure changed