refactor; compile calls and global statements