Improve layouts

Change 'analysis' to 'layer', reserve it for future usage. Move sorter
to libbta.