flatten can be dramatically simpler, when I think about it
add remove function for lists
some bug fixes