Added lots of checking and automatic logging to lsa package