Split block() into two functions

Indentation level went above 3, which is not fine.
[alsa] Add cleanup
Add memory module