some code styling / bug fixing