cleaned up code

cleaned up the code and added made LS learn run in async