Before cleanup. Working version.