Added flat map method, minor tweaks