WIP

various fixes. TODO: stop using []