First bunch of bug fixes: works -w, -l. Not tested yet with -s