flex mostly implemented. few bugs remain

Signed-off-by: Phil <prbaylog@gmail.com>