refactor and "improve" some old erlang solutions